package com.poorstu.web.studentApply;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.common.base.web.BaseAction;
import com.poorstu.manager.BursaryManager;
import com.poorstu.model.BursaryMod;

public class BursaryManagerAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		try{
			int allUserId=(Integer)request.getSession().getAttribute("allUserId");
			BursaryManager bursaryManager=(BursaryManager)getBean("bursaryManager");
			List<BursaryMod> bursaryList=new ArrayList<BursaryMod>();
			bursaryList=bursaryManager.getBursary(allUserId);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			for(int i=0;i<bursaryList.size();i++)
			{
				bursaryList.get(i).setApptime(sdf.format(bursaryList.get(i).getBurTime()));
		    
			}
			
			
			request.setAttribute("bursaryList", bursaryList);
			return mapping.findForward("succ");
		}
		catch(Exception e){
			e.printStackTrace();
			return mapping.findForward("failure");
		}
		
	}
	
	
	

}
